package com.shuai.frame.protocol;

import lombok.Getter;

@Getter
public enum ProtocolMessageTypeEnum {
    REQUEST(0, "请求"),
    RESPONSE(1, "响应"),
    HEART_BEAT(2, "心跳"),
    OTHERS(3, "其他");

    private final int code;
    private final String desc;

    ProtocolMessageTypeEnum(int code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public static ProtocolMessageTypeEnum getEnum(int code) {
        for (ProtocolMessageTypeEnum typeEnum : ProtocolMessageTypeEnum.values()) {
            if (typeEnum.getCode() == code) {
                return typeEnum;
            }
        }
        return null;
    }
}
